/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Project.bussiness;

import Project.DBHelper;
import java.io.File;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.Vector;


/**
 *
 * @author Handsome
 */

public class Config {
    private static int hour=0;
    private static int min = 0;
    private static boolean auto = true;
    private static String pathbk = "backup";
   // private static AutoBackup autoBackup = new AutoBackup();
public static void setConfig(int h, int m, String p, Boolean a)
{
    try {
            setHour(h);
            setMin(m);
            setPathbk(p.trim());
            setAuto(a);
            Vector paramList = new Vector();
            paramList.add(h);
            paramList.add(m);
            paramList.add(p.trim());
            paramList.add(a);
            ResultSet rs = DBHelper.executeQuery("getConfig");
            if(rs!=null){
                  DBHelper.executeUpdate("setConfig",paramList);}
            else {
                  DBHelper.executeQuery("insertConfig",paramList);
            }
        } catch(SQLException sqle) {
            sqle.printStackTrace();
        }

}
//public static void getConfig()
//    {
//       try {
//        ResultSet rs = DBHelper.executeQuery("getConfig");
//          while(rs.next()){
//                setHour(rs.getInt(1));
//                setMin(rs.getInt(2));
//                setPathbk(rs.getString(3).trim());
//                setAuto(rs.getBoolean(4));
//             }
//        rs.close();
//        } catch(SQLException sqle) {
//            sqle.printStackTrace();
//        }
//
//    }

    /**
     * @return the hour
     */
    public static int getHour() {
        return hour;
    }

    /**
     * @param aHour the hour to set
     */
    public static void setHour(int aHour) {
        hour = aHour;
    }

    /**
     * @return the min
     */
    public static int getMin() {
        return min;
    }

    /**
     * @param aMin the min to set
     */
    public static void setMin(int aMin) {
        min = aMin;
    }

    /**
     * @return the auto
     */
    public static boolean isAuto() {
        return auto;
    }

    /**
     * @param aAuto the auto to set
     */
    public static void setAuto(boolean aAuto) {
        auto = aAuto;
    }

    /**
     * @return the path
     */
    public static String getPathbk() {
        return pathbk;
    }

    /**
     * @param aPath the path to set
     */
    public static void setPathbk(String aPath) {
        pathbk = aPath;
    }
public static void StopAuto(){
 //  autoBackup.cancel();
   //autoBackup = new AutoBackup();
}
public static void AutoBackup()
{
    if(isAuto()==true){
                    File f = new File(getPathbk());
                    if(!f.exists())
                    f.mkdirs();
                 //   autoBackup.setBackupPath(f.getAbsolutePath());
                    //autoBackup.start(getHour(), getMin());
                }

}
    

    /**
     * @return the hour
     */
   
}
